<template>
	<view class="record-parent">
		<view class="record-top-view" style="width: 100%;height: 394rpx;background-color: #FF5E06;
		align-items: center;justify-content: center;display: flex;flex-direction: column;">
			<view style="display: flex;flex-direction: row;justify-content: center;align-items: center;">
				<text v-if="allMoney" style="font-size: 100rpx;font-weight: 500;color: #FFFFFF;line-height: 100rpx;">{{allMoney}}</text>
				<text v-else style="font-size: 100rpx;font-weight: 500;color: #FFFFFF;line-height: 100rpx;">0</text>
				<text style="font-size: 26rpx;font-weight: 500;color: #FFFFFF;line-height: 26rpx;margin-left: 20rpx;">(个)</text>
			</view>
			<view style="width: 528rpx;height: 70rpx;background-color: rgba(255, 255, 255,0.23);align-items: center;justify-content: center;
			border-radius: 35rpx;margin-top: 68rpx;flex-direction: row;display: flex;">
				<text v-if="income" style="font-size: 28rpx;font-weight: bold;color: #FAFAFA;line-height: 28rpx;">本月奖励：{{income}}</text>
				<text v-else style="font-size: 28rpx;font-weight: bold;color: #FAFAFA;line-height: 28rpx;">本月奖励：0</text>
				<text v-if="expend" style="font-size: 28rpx;font-weight: bold;color: #FAFAFA;line-height: 28rpx;margin-left: 30rpx;">本月支出：{{expend}}</text>
				<text v-else style="font-size: 28rpx;font-weight: bold;color: #FAFAFA;line-height: 28rpx;margin-left: 30rpx;">本月支出：0</text>
			</view>
		</view>
		<view class="list-parent">
			<view class="list-item"  v-for="(item , index) in list" :key="'item'+index">
				 <view style="width: 100%;padding-left: 59rpx;padding-right:59rpx;display: flex;flex-direction: row;height: 35rpx;
				 box-sizing: border-box;">
					 <text style="font-size: 30rpx;font-weight: bold;color: #000000;line-height: 30rpx;flex: 1;">{{item.memo}}</text>
					 <text v-if="item.in=='1'" style="font-size: 34rpx;font-weight: bold;color: #FF4206;line-height: 34rpx;">+{{item.money}}</text>
					 <text v-else style="font-size: 34rpx;font-weight: bold;color: #000000;line-height: 34rpx;">{{item.money}}</text>
				 </view>
				 <view style="width: 100%;padding-left: 59rpx;padding-right:59rpx;display: flex;flex-direction: row;height: 30rpx;
				 box-sizing: border-box;margin-top: 25rpx;">
					 <text style="font-size: 28rpx;font-weight: bold;color: #B8B8B8;line-height: 28rpx;flex: 1;">{{item.time | formatDate('-')}}</text>
					 <text  style="font-size: 28rpx;font-weight: bold;color: #B8B8B8;line-height: 28rpx;">余额：{{item.after}}</text>
				 </view>
			</view>
		</view>
		<LoginTipDialog :isShow="isShowLoginTip" dataSource="登录查看具体信息"  @returnLoginTipDialog="returnLoginTipDialog"/>
	</view>
</template>

<script>
	import request from '../index/request.js';
	import LoginTipDialog from "@/components/login-tip-dialog/login-tip-dialog.vue";
	export default {
		components: {
			LoginTipDialog
		},
		data() {
			return {
				isShowLoginTip:false,
				allMoney:"",
				income:"",
				expend:"",
				list:[],
				page:1,
			}
		},
		filters:{
			// 时间戳处理
			formatDate: function(value,spe='/') {
			   value = value*1000
			   let data= new Date(value);
			   let year = data.getFullYear();
			   let month = data.getMonth() + 1;
			   let day = data.getDate();
			   let h = data.getHours();
			   let mm = data.getMinutes();
			   let s = data.getSeconds();
			   month = month > 10 ? month : "0" + month;
			   day = day > 10 ? day : "0" + day;
			   h = h >=10 ? h : "0" + h;
			   mm = mm >= 10 ? mm : "0" + mm;
			   s = s >= 10 ? s : "0" + s;
			   return `${year}${spe}${month}${spe}${day} ${h}:${mm}:${s}`;
			}
		},
		methods: {
			returnLoginTipDialog:function(e){
				this.isShowLoginTip=e.isclose
				if(e.tag){
					uni.navigateTo({
						url:"../index/index"
					})
				}
			},
			onLoad:function(options){
				this.appUtil.saveAppInviteId(options)
			},
			onShow:function(){
				var user=uni.getStorageSync("shiqin-user")
				this.share.url='/pages/tabBar/home/index?appInviteId='+this.appUtil.getAppInviteId()
				this.share.shareType=1
				if (user.PQD) {
					if(this.list.length==0){
						uni.startPullDownRefresh()
					}
				}else{
					this.isShowLoginTip=true
				}
			},
			//下拉刷新
			onPullDownRefresh:function(){
				this.page=1
				this.getData()
			},
			//上拉加载更多
			onReachBottom:function(){
				this.page=this.page+1
				this.getData()
			},
			//获取数据
			getData:function(){
				var that=this
				request.post("api/user/YB_jilu",{
					page:this.page,
				}).then(data=>{
					uni.stopPullDownRefresh()
					that.allMoney=data.all
					that.income=data.add
					that.expend=data.end
					if(that.page==1){
						this.list=data.log;
					}else{
						for (var i = 0; i < data.log.length; i++) {
							this.list.push(data.log[i]);
						}
					}
				})
			},
		}
	}
</script>

<style>
	@import "index.css";
</style>
